package de.openkanban.client.ui.presenter;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.smartgwt.client.util.SC;

import de.openkanban.client.ui.board.ActivityView;
import de.openkanban.client.ui.board.KanbanView;
import de.openkanban.client.util.RootPanel;
import de.openkanban.shared.dto.StatusDto;

public class RemoveKanbanRequestCallback implements RequestCallback {
	
	private KanbanView kanbanView;
	
	public RemoveKanbanRequestCallback(KanbanView kanbanView) {
		this.kanbanView = kanbanView;
	}

	@Override
	public void onResponseReceived(Request request, Response response) {
		StatusDto statusDto = new StatusDto(response.getText());
		if (statusDto.isCallSuccessfull()) {
			ActivityView activityView = RootPanel.main.getBoard().getWhiteBoardView().getActivityViewById(kanbanView.getParentActivityId());
			activityView.removeKanbanView(kanbanView.getKanbanDto().getKanbanId());
		} else {
			SC.say("Error occured removing Kanban");
		}
	}

	@Override
	public void onError(Request request, Throwable exception) {
	}

}
